package me.zhengjie.state;

import lombok.Getter;

@Getter
public enum PriorityEnum {

    // 定义优先级级别，从低到高
    LOW(1, "低优先级", "可以稍后处理，对整体目标影响较小的任务"),
    TWO(2, "低优先级", "可以稍后处理，对整体目标影响较小的任务"),
    MEDIUM(3, "中优先级", "需要处理，但没有明确时间限制的任务"),
    FOUR(4, "中优先级", "需要处理，但没有明确时间限制的任务"),
    HIGH(5, "中优先级", "需要尽快处理，对业务有重要影响的任务"),
    SIX(6, "高优先级", "需要尽快处理，对业务有重要影响的任务"),
    SEVEN(7, "高优先级", "需要尽快处理，对业务有重要影响的任务"),
    URGENT(8, "紧急优先级", "需要立即处理，可能影响系统运行或业务流程的任务"),
    NINE(8, "紧急优先级", "需要立即处理，可能影响系统运行或业务流程的任务"),
    CRITICAL(10, "关键优先级", "需要立即处理，可能导致严重后果的任务");

    // 获取优先级权重值
    // 优先级权重值
    private final int weight;
    // 获取优先级名称
    // 优先级名称
    private final String name;
    // 获取优先级描述
    // 优先级描述
    private final String description;

    // 构造函数
    PriorityEnum(int weight, String name, String description) {
        this.weight = weight;
        this.name = name;
        this.description = description;
    }

    // 根据权重值获取优先级
    public static PriorityEnum fromWeight(int weight) {
        for (PriorityEnum priority : values()) {
            if (priority.getWeight() == weight) {
                return priority;
            }
        }
        // 默认返回中优先级
        return MEDIUM;
    }

    // 比较两个优先级的大小
    public boolean higherThan(PriorityEnum other) {
        return this.weight > other.weight;
    }

    // 比较两个优先级的大小
    public boolean lowerThan(PriorityEnum other) {
        return this.weight < other.weight;
    }
}
